package com.zhouyihe.weblog.admin.controller;

import com.zhouyihe.weblog.admin.model.vo.category.AddCategoryReqVO;
import com.zhouyihe.weblog.admin.model.vo.category.DeleteCategoryReqVO;
import com.zhouyihe.weblog.admin.model.vo.category.FindCategoryPageListReqVO;
import com.zhouyihe.weblog.admin.service.AdminCategoryService;
import com.zhouyihe.weblog.common.aspect.ApiOperationLog;
import com.zhouyihe.weblog.common.utils.PageResponse;
import com.zhouyihe.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AdminCategoryController
 * @author: 周益和
 * @qq: 1552951165
 * @date: 2024/6/2
 * @description:
 */
@RestController
@RequestMapping("/admin")
@Api(tags = "Admin 分类模块")
public class AdminCategoryController {
    
    @Autowired
    private AdminCategoryService categoryService;
    
    
    /**
     * 添加分类
     *
     * @param addCategoryReqVO 包含新增分类信息的请求体。
     * @return 返回添加分类的操作结果。
     */
    @PostMapping("/category/add")
    @ApiOperation(value = "添加分类")
    @ApiOperationLog(description = "添加分类")
    public Response addCategory(@RequestBody @Validated AddCategoryReqVO addCategoryReqVO) {
        return categoryService.addCategory(addCategoryReqVO);
    }
    
    /**
     * 获取分类的分页数据
     *
     * @param findCategoryPageListReqVO 包含查询条件的请求体。
     * @return 返回分类分页数据。
     */
    @PostMapping("/category/list")
    @ApiOperation(value = "分类分页数据获取")
    @ApiOperationLog(description = "分类分页数据获取")
    public PageResponse findCategoryPageList(@RequestBody @Validated FindCategoryPageListReqVO findCategoryPageListReqVO) {
        return categoryService.findCategoryPageList (findCategoryPageListReqVO);
    }
    
    /**
     * 根据id删除分类
     * @param deleteCategoryReqVO
     * @return
     */
    @PostMapping("/category/delete")
    @ApiOperation(value = "删除分类")
    @ApiOperationLog(description = "删除分类")
    public Response deleteCategory(@RequestBody @Validated DeleteCategoryReqVO deleteCategoryReqVO) {
        return categoryService.deleteCategory(deleteCategoryReqVO);
    }
    
    /**
     * 查询所有的分类信息
     * 分类 Select 下拉列表数据获取
     * @return
     */
    @PostMapping("/category/select/list")
    @ApiOperation(value = "分类 Select 下拉列表数据获取")
    @ApiOperationLog(description = "分类 Select 下拉列表数据获取")
    public Response findCategorySelectList() {
        return categoryService.findCategorySelectList();
    }
}
